#include <bits/stdc++.h>
using namespace std;
int n, Q, b[10005];
struct node {
	int num, pos;
	bool operator < (const node &AI) const {
		if (AI.num == num) return pos < AI.pos;
		else return num < AI.num;
	}
}a[10005];
int main() {
	freopen("sort.in", "r", stdin);
	freopen("sort.out", "w", stdout);
	cin >> n >> Q;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i].num);
		a[i].pos = i;
	}
	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n; ++i) b[a[i].pos] = i;
//	for (int i = 1; i <= n; ++i) printf("%d ", b[i]);
//	return 0;
	for (int opt, x, v; Q != 0; --Q) {
		opt = 0, x = 0, v = 0;
		scanf("%d", &opt);
		if (opt == 1) {
			scanf("%d%d", &x, &v);
			a[b[x]].num = v;
			if (a[b[x] - 1].num > a[b[x]].num) {
				for (int i = b[x]; i > 1; --i) {
					if (a[i].num < a[i - 1].num) {
						++b[a[i - 1].pos];
						--b[a[i].pos];
						node tmp = a[i];
						a[i] = a[i - 1];
						a[i - 1] = tmp;
					}
				}
			}
			if (a[b[x] + 1].num < a[b[x]].num) {
				for (int i = b[x]; i < n; ++i) {
					if (a[i].num > a[i + 1].num) {
						--b[a[i + 1].pos];
						++b[a[i].pos];
						node tmp = a[i];
						a[i] = a[i + 1];
						a[i + 1] = tmp;
					}
				}
			}
			for (int i = b[x]; i > 1 && a[i - 1].pos > a[i].pos && a[i - 1].num == a[i].num; --i) {
				++b[a[i - 1].pos];
				--b[a[i].pos];
				node tmp = a[i];
				a[i] = a[i - 1];
				a[i - 1] = tmp;
			}
			for (int i = b[x]; i < n && a[i + 1].pos < a[i].pos && a[i + 1].num == a[i].num; ++i) {
				--b[a[i + 1].pos];
				++b[a[i].pos];
				node tmp = a[i];
				a[i] = a[i + 1];
				a[i + 1] = tmp;
			}
		}
		if (opt == 2) {
			scanf("%d", &x);
			printf("%d\n", b[x]);
		}
	}
	return 0;
}
